// 0，1，1,2,3,5,8,13....
function fibMeno3(n: number): number {
  // 定义状态
  // let dp :number[] = [];

  // 状态转移
  //dp[i] = dp[i-1] + dp[i-2]

  if(n<=1){
    return n
  }

  let prev = 0
  let cur = 1

  for (let i = 2; i <= n; i++) {

    const newValue = prev + cur
    prev = cur
    cur = newValue    
  }  
  
  return cur;
}

console.log(fibMeno3(2));
console.log(fibMeno3(3));
console.log(fibMeno3(4));
